import { DirectiveBinding, VNode } from '@vue/runtime-core'
import store from '../../store'

const showButton = {
  beforeMount (el: HTMLElement, binding: DirectiveBinding, vnode: VNode) {
    let flag =  judgeButton(binding.value)
    if (!flag) {
      el.style.display = 'none'
    }
  }
}

const judgeButton = (val: string | number) => {
  let accountType = store.getters.accountType
  let roleBtn = store.getters.btnList[accountType]
  console.log(accountType, val, roleBtn);
  return roleBtn.includes(val)
}

export default showButton
